Skip to content

docs: explain empty reports when __coverage__ is created after load (#843) - #1014

Merged
jennifer-shehane merged 2 commits into
masterfrom
claude/code-coverage-843-reverify-yte053
Nov 2, 2026
Merged

jennifer-shehane merged 2 commits into
masterfrom
claude/code-coverage-843-reverify-yte053

Conversation

@jennifer-shehane

@jennifer-shehane jennifer-shehane commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Additional details

I re-verified #843 against master using the reporter's public Nuxt 3 + vite-plugin-istanbul repro. The bug is already fixed in 4.1.2, so this PR only adds a README note to help people who still hit it on older versions.

What caused it: the repro only instruments pages/* and utils/*, and Nuxt imports page components lazily. On the Nuxt dev server, window.__coverage__ was created after the page's load event on every load I recorded (by 6–226 ms). Up to 4.1.1, the plugin read coverage only on window:load and at the start of each test, before the test's own cy.visit. So it saw nothing and wrote an empty out.json, even though DevTools showed the object.

Why it's already fixed: #1007 (released in 4.1.2) also reads each page in window:before:unload and in afterEach. I compared the published 4.1.1 and 4.1.2 bundles to confirm the boundary. test-apps/swc-webpack already guards this in CI: its only instrumented bundle is injected after load, the same shape as the repro. So I didn't add another test app.

Spec filtering isn't involved. I ran the repro's real coverage keys through filterFilesFromCoverage with its specPattern and support file, and both app files were kept.

The change: a new Common issues entry, "window.__coverage__ exists but the report is empty". It names the symptom, explains the timing, and says to upgrade to 4.1.2 or later. It also links 3.x users to the 3.x to 4.x migration section, since that upgrade is breaking (Cypress ≥ 15.10, env → expose).

Steps to test

  1. Read the new section under Common issues in README.md.
  2. Check that the #cypresscode-coverage-3x-to-4x link jumps to the migration section (npx markdown-link-check README.md reports it as ✓).
  3. npm run format:check passes. There are no code changes.

How has the user experience changed?

No change to plugin behavior. The README has a new troubleshooting entry for this symptom.


Generated by Claude Code


Note

Low Risk
Documentation-only change with no code, config, or test modifications.

Overview
Adds a Common issues troubleshooting entry for when DevTools shows window.__coverage__ but .nyc_output/out.json stays empty. The note explains that lazy-loaded or hydration-time instrumentation can create the coverage object after the page load event, which older plugin versions (before 4.1.2) did not capture because they only read coverage on load and at test start.

The section directs users to upgrade to 4.1.2+ (which also reads before unload and in afterEach), points 3.x users at the existing migration anchor, and links issue #843. No runtime or plugin behavior changes—README only.

Reviewed by Cursor Bugbot for commit 5792459. Bugbot is set up for automated code reviews on this repo. Configure here.

…843)

Nuxt 3 with vite-plugin-istanbul only instruments lazily imported page
modules, so window.__coverage__ is created after the page's load event.
Versions before 4.1.2 read coverage only on load and wrote an empty
out.json. 4.1.2 (#1007) also reads each page before it unloads and at
the end of each test, and test-apps/swc-webpack guards that behavior.

Add a Common issues entry so users still on 3.x who see the coverage
object in DevTools but get an empty report know to upgrade.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WUv8r1DKMrtbUrcHzyPuof
@jennifer-shehane
jennifer-shehane merged commit aa91ec8 into master Nov 2, 2026
32 checks passed
@jennifer-shehane
jennifer-shehane deleted the claude/code-coverage-843-reverify-yte053 branch November 2, 2026 00:42
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 4.1.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cypress cannot see the window.__coverage__ object

2 participants